package com.zyf.school.manager.domain;

import lombok.*;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
@ToString
public class DictTree {
    private int id;
    private String title;

    public DictTree(int id, String title) {
        this.id = id;
        this.title = title;
    }

    private List<DictTree> children = new ArrayList<>();

    public static List<Tree> toTree(List<Tree> tree , List<Dict> Dict){
        for (int i=0; i<Dict.size(); i++){
            Tree t = new Tree();
            t.setId(String.valueOf(Dict.get(i).getId()));
            t.setTitle(Dict.get(i).getName());
            tree.add(t);
            toTree(t.getChildren(),Dict.get(i).getList());
        }
        return tree;
    }
}
